import { validateNameCNLU, nameErrorTipCNLU, getNumReg } from '@/libs/reg';
import { queryAllProject } from '../api/projectManage.js';
import { typeRecordMixin } from '../mixin/research';
const formDataMixin = {
    mixins:[typeRecordMixin],
    data() {
        return {
            xmList:[],
            formData:{
                name:{
                    value:'',
                    label:'科研名称',
                    component:'Input',
                    placeholder:nameErrorTipCNLU,
                    rule:{
                        required: true,
                        validator: validateNameCNLU
                    },
                    props:{
                        maxlength:64
                    }
                },
                // typeId:{
                //     value:'',
                //     label:'科研类型',
                //     component:'Select',
                //     options:() => {
                //         return this.typeRecordData
                //     }
                // },
                manageId: {
                    value:'',
                    label:'归属项目',
                    component:'Select',
                    options:() => {
                        return this.xmList.map(item => {
                            return {
                                ...item,
                                label:item.name,
                                value:item.id
                            }
                        })
                    }
                },
                description: {
                    value:'',
                    component:'Input',
                    label:'描述',
                    props:{
                        type:'textarea',
                        autosize:{minRows: 2,maxRows: 5},
                        maxlength:200
                    },
                }
            }
        }
    },
    computed:{
       
    },
    methods: {
        queryXmList() {
            queryAllProject().then((res) => {
                if (res.code == 1) {
                    this.xmList = res.data;
                }
            }).finally(() => {
                
            });
        },
        getOptionsData(item) {
            return typeof item.options === 'function'
                ? item.options()
                : item.options
                ? item.options
                : [];
        },
    }
};
export { formDataMixin };
